Skip to main content

sc.utf8

Functions for handling and manipulating UTF-8 encoded strings (for Computer API)

Functions

getCharacterAt

sc.utf8.getCharacterAt( str, index )

Returns the UTF-8 character starting at the given byte index in the string.

Arguments:

  • str [ string ] The UTF-8 encoded string.
  • index [ integer ] The byte index in the string where the character starts (1-based index).

Returns:

  • [ string ] The full UTF-8 character at the given byte index.
  • [ integer ] The number of bytes in the character.

getStringSize

sc.utf8.getStringSize( str )

Returns the number of UTF-8 characters in the string.

Arguments:

  • str [ string ] The UTF-8 encoded string.

Returns:

  • [ number ] The number of UTF-8 characters in the string.

loopCharacters

sc.utf8.loopCharacters( str )

Returns an iterator function that loops through each UTF-8 character in the string.

Arguments:

  • str [ string ] The UTF-8 encoded string to iterate over.

Returns:

  • [ function ] An iterator function which returns the next UTF-8 character each time it is called.